package com.freak.mvvmhelper.base.activity;

import android.app.Dialog;
import android.content.pm.ActivityInfo;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.freak.mvvmhelper.app.CommonApp;
import com.freak.mvvmhelper.base.lifecycle.MyLifecycleObserver;

import org.greenrobot.eventbus.EventBus;

import static com.freak.mvvmhelper.app.CommonApp.DESIGN_WIDTH;

public class BaseActivity extends AppCompatActivity   {
    private AppCompatActivity mActivity;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //限制竖屏
        //8.0.0版本系统，同时设置竖屏和设置全屏透明冲突，
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        CommonApp.resetDensity(this, DESIGN_WIDTH);
        //活动控制器
        mActivity = this;
        CommonApp.getInstance().addActivity(this, this.getClass());
        EventBus.getDefault().register(this);
        getLifecycle().addObserver(new MyLifecycleObserver());
    }

    @Override
    protected void onRestart() {
        super.onRestart();

    }

    @Override
    protected void onStart() {
        super.onStart();
    }

    @Override
    protected void onResume() {
        super.onResume();

    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        CommonApp.getInstance().removeActivity(this);
        EventBus.getDefault().unregister(this);
    }


}
